<template>
    <el-form :inline="true">
        <el-form-item label="一级分类">
            <el-select v-model="categoryStore.category1Id" placeholder="请选择" @change="categoryStore.getCategory2" :disabled="disabled" >
                <el-option 
                    v-for="category1 in categoryStore.category1List"
                    :key="category1.id" 
                    :label="category1.name" 
                    :value="category1.id" 
                />
            </el-select>
        </el-form-item>
        <el-form-item label="二级分类">
            <el-select v-model="categoryStore.category2Id" placeholder="请选择" @change="categoryStore.getCategory3" :disabled="disabled">
                <el-option 
                    v-for="category2 in categoryStore.category2List"
                    :key="category2.id"
                    :label="category2.name" 
                    :value="category2.id" 
                />
            </el-select>
        </el-form-item>
        <el-form-item label="三级分类">
            <el-select v-model="categoryStore.category3Id" placeholder="请选择" :disabled="disabled">
                <el-option 
                    v-for="category3 in categoryStore.category3List" 
                    :key="category3.id"
                    :label="category3.name" 
                    :value="category3.id" 
                />
            </el-select>
        </el-form-item>
    </el-form>
</template>

<script lang="ts">
export default {
    name: 'CategorySelector'
}
</script>

<script setup lang="ts">
import useCategoryStore from '@/stores/category'
import { onMounted } from 'vue';
const categoryStore = useCategoryStore()
onMounted(() => {
    categoryStore.getCategory1();
})
defineProps<{
    disabled:boolean
}>()
</script>

<style scoped>

</style>